<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>AIMES-APS</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <style type="text/css">
      html,
      body {
        margin: 0;
        padding: 0;
        /* font-family: '思源黑体'; */
        font-family: -apple-system,BlinkMacSystemFont,'Helvetica Neue',Helvetica,Segoe UI,Arial,Roboto,'PingFang SC',miui,'Hiragino Sans GB','Microsoft Yahei', sans-serif;
        font-size: 14px;
        height: 100%;
        width: 100%;
        overflow: hidden;
        color: #ffffff;
      }

      p,
      h1,
      h5 {
        padding: 0;
        margin: 0;
      }

      .center {
        text-align: center;
      }

      @media screen and (max-width: 750px) {
        .nav {
          float: left;
          background-image: url('./FHimg/mobile.png');
          background-repeat: no-repeat;
          background-size: 100% 100%;
          height: 100%;
          width: 100%;
        }

        .loading {
          background-size: 100% 100%;
          background-image: url('./FHimg/mobile.gif');
          height: 3.2rem;
          width: 3.2rem;
          background-repeat: no-repeat;
          margin: 0 auto;
          margin-top: 5%;
        }
      }

      @media screen and (min-width: 750px) {
        .nav {
          float: left;
          background-image: url('./FHimg/pc.png');
          width: 100%;
          height: 100%;
        }

        .loading {
          background-size: 100% 100%;
          background-image: url('./FHimg/pc.gif');
          height: 3.5rem;
          width: 3.5rem;
          background-repeat: no-repeat;
          margin: 0 auto;
          margin-top: 5%;
        }
      }

      .h1 {
        width: 100%;
        margin-top: 50px;
      }

      .h5 {
        width: 100%;
        margin-top: 10px;
        margin-bottom: 50px;
        color: #fff;
      }

      .fontsize {
        position: fixed;
        left: 0;
        bottom: 75px;
        width: 100%;
        font-size: 14px;
        text-align: center;
        color: #fff;
      }

      .footer {
        position: fixed;
        left: 0;
        bottom: 20px;
        width: 100%;
        text-align: center;
        font-size: 10px;
        color: #fff;
      }
    </style>
    <script>
      !(function(e, t) {
        function n() {
          var n = l.getBoundingClientRect().width
          ;(t = t || 540), n > t && (n = t)
          var i = (100 * n) / e
          r.innerHTML = 'html{font-size:' + i + 'px;}'
        }
        var i,
          d = document,
          o = window,
          l = d.documentElement,
          r = document.createElement('style')
        if (l.firstElementChild) l.firstElementChild.appendChild(r)
        else {
          var a = d.createElement('div')
          a.appendChild(r), d.write(a.innerHTML), (a = null)
        }
        n(),
          o.addEventListener(
            'resize',
            function() {
              clearTimeout(i), (i = setTimeout(n, 300))
            },
            !1
          ),
          o.addEventListener(
            'pageshow',
            function(e) {
              e.persisted && (clearTimeout(i), (i = setTimeout(n, 300)))
            },
            !1
          ),
          'complete' === d.readyState
            ? (d.body.style.fontSize = '16px')
            : d.addEventListener(
                'DOMContentLoaded',
                function(e) {
                  d.body.style.fontSize = '16px'
                },
                !1
              )
      })(750, 750)
    </script>
  </head>

  <body>
    <div class="nav">
      <header>
        <h1 class="h1 center">
          致链工业互联网平台
        </h1>
        <h5 class="h5 center">
          家居制造业一体化解决方案
        </h5>
      </header>
      <section>
        <div class="loading"></div>
        <div class="fontsize">
          系统正在连接中，请稍等...
        </div>
      </section>
      <footer>
        <div class="footer">
          Copyright 德阳市致链数字科技有限公司
          <a target="_blank" href="http://beian.miit.gov.cn" style="color:#fff;text-decoration: none;display: block;">蜀ICP备20020570号</a>
        </div>
      </footer>
    </div>
    <script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="//g.alicdn.com/dingding/dingtalk-jsapi/2.0.57/dingtalk.open.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/js-base64@3.6.0/base64.min.js"></script>
  </body>

  <script type="text/javascript">
    function openlink() {
      window.location.reload(true)
    }

    function _isMobile() {
      //判断是PC还是手机
      let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
      return flag
    }
    let baseURL = ''
    $(function() {
      baseURL = document.location.origin
      doLogin()
    })

    /**
     *
     * 功能描述:  钉钉登录
     * @auther: sq
     * @date: 2020/07/24 14:33
     */
    function doLogin() {
      let that = this
      var _config = {}
      var sourceUrl = document.location.href
      var jiedian = GetQueryString('jiedian')
      if (jiedian == 'active') {
        jiedian = 1
      }
      var loginfrom = GetQueryString('loginfrom')
      if (loginfrom == 'abnormalStorage') {
        sourceUrl = baseURL + '/bdsoms-web/#/mobile/abnormalStorage/'
      }
      var number = GetQueryString('number')
      $.ajax({
        url: baseURL + '/ly-code-admin-servicer/oauth-client-details/ddSignInfo?url=' + sourceUrl, //测试服
        dataType: 'json',
        type: 'GET',
        beforeSend: function(xhr) {
          xhr.setRequestHeader('jx_Authorization', 'Basic YWltZXM6YWltZXNfc2VjcmV0')
        },
        success: function(res) {
          //获取签名信息成功
          _config = res.responseBody
          dd.config({
            agentId: _config.agentId,
            corpId: _config.corpId,
            timeStamp: _config.timeStamp,
            // nonceStr: _config.nonceStr,
            nonceStr: _config.nonce,
            signature: _config.signature,
            jsApiList: ['runtime.info', 'device.notification.prompt', 'biz.chat.pickConversation', 'device.notification.confirm', 'device.notification.alert', 'device.notification.prompt', 'biz.chat.open', 'biz.util.open', 'biz.user.get', 'biz.contact.choose', 'biz.telephone.call', 'biz.util.uploadImage', 'biz.ding.post'],
          })
          dd.runtime.permission.requestAuthCode({
            corpId: _config.corpId, // 企业id
            onSuccess: function(info) {
              var code = info.code // 通过该免登授权码可以获取用户身份
              $.ajax({
                url: baseURL + '/ly-code-auth-servicer/oauth/token?third_code=' + code + '&grant_type=third_code', //测试服
                type: 'GET',
                beforeSend: function(xhrs) {
                  xhrs.setRequestHeader('jx_Authorization', 'Basic YWltZXM6YWltZXNfc2VjcmV0')
                },
                success: function(res) {
                  let code = JSON.stringify(res)
                  let api = res
                  if (_isMobile()) {
                    if (loginfrom == 'abnormalStorage') {
                      dd.biz.util.openLink({
                        url: baseURL + '/bdsoms-web/#/mobile/abnormalStorage/?token=' + api.access_token + '&refresh_token=' + api.refresh_token, //测试服
                        onSuccess: function(result) {
                          console.log(result)
                        },
                        onFail: function(err) {
                          console.log(err)
                        },
                      })
                    } else {
                      dd.biz.util.openLink({
                        url: baseURL + '/bdsoms-web/#/?token=' + api.access_token + '&refresh_token=' + api.refresh_token, //测试服
                        onSuccess: function(result) {
                          console.log(result)
                        },
                        onFail: function(err) {
                          console.log(err)
                        },
                      })
                    }
                  } else {
                    if (loginfrom == 'abnormalStorage') {
                      dd.biz.util.openLink({
                        url: baseURL + '/bdsoms-web/#/mobile/abnormalStorage/?token=' + api.access_token + '&refresh_token=' + api.refresh_token, //测试服
                        onSuccess: function(result) {
                          console.log(result)
                        },
                        onFail: function(err) {
                          console.log(err)
                        },
                      })
                    } else {
                      dd.biz.util.openLink({
                        url: baseURL + '/bdsoms-web/#/?token=' + api.access_token + '&refresh_token=' + api.refresh_token, //测试服
                        onSuccess: function(result) {
                          console.log(result)
                        },
                        onFail: function(err) {
                          console.log(err)
                        },
                      })
                    }
                  }
                },
              })
            },
            onFail: function(err) {
              // alert('fail: ' + JSON.stringify(err));
            },
          })
          dd.error(function(error) {
            // alert('dd error: ' + JSON.stringify(error));
          })
        },
        error: function(e) {
          console.log(e)
        },
      })
    }

    /**
     * 获取地址栏参数信息
     * */
    function GetQueryString(name) {
      var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)')
      var r = window.location.search.substr(1).match(reg)
      if (r != null) return unescape(r[2])
      return null
    }
  </script>
</html>
